package _18define;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DaySince {
    public static void main(String[] args) throws ParseException {
        String time="2001-12-27";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date birth=sdf.parse(time);
        long birthTime=birth.getTime();
        String days=daySince(birthTime);
        System.out.println("已来到这个世界"+days);

    }
    public static String daySince(long birth){
        long nowTime=System.currentTimeMillis();
        long nd=1000*24*60*60;
        long nh=1000*60*60;
        long nm=1000*60;
        long diff=nowTime-birth;
        long day=diff/nd;
        long hour=diff%nd/nh;
        long min=diff%nd%nh/nm;
        long second=diff%nd%nh%nm/1000;
        return day+"天"+hour+"小时"+min+"分钟"+second+"秒";
    }
}
